package com.tcm.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * 配置文件封装类
 * @author Guqier
 * @version 1.0
 * @date 2023/7/1 22:26
 */
@Data
@Component
@ConfigurationProperties(value = "app")
public class AppProperties {

    /* 用户类型，0表示管理员，1表示老师，2表示学生，3表示社会化学员 */
    /**
     * 管理员用户类型
     */
    public static final Integer ADMIN_USER_TYPE = 0;

    /**
     * 教师用户类型
     */
    public static final Integer TEACHER_USER_TYPE = 1;

    /**
     * 学生用户类型
     */
    public static final Integer STUDENT_USER_TYPE = 2;

    /**
     * 社会化学员用户类型
     */
    public static final Integer SOCIAL_STUDENT_USER_TYPE = 3;

    /**
     * 管理端允许登录用户类型
     */
    public static final Integer[] BACKEND_LOGIN_ALLOW_USER_TYPE = {ADMIN_USER_TYPE, TEACHER_USER_TYPE};

    /**
     * 学生端允许登录用户类型
     */
    public static final Integer[] FRONT_LOGIN_ALLOW_USER_TYPE = {STUDENT_USER_TYPE, SOCIAL_STUDENT_USER_TYPE};

    /**
     * 图片类型：用户头像
     */
    public static final Integer IMAGE_TYPE_AVATAR = 0;

    /**
     * 图片类型：课程封面
     */
    public static final Integer IMAGE_TYPE_COURSE = 2;

    /**
     * 章节学习情况：未学习
     */
    public static final Integer LEARNING_STATUS_NOT_LEARN = 0;

    /**
     * 章节学习情况：学习中
     */
    public static final Integer LEARNING_STATUS_LEARNING = 1;

    /**
     * 章节学习情况：已学完
     */
    public static final Integer LEARNING_STATUS_LEARNED = 2;

    /**
     * 题目类型：主观题
     */
    public static final Integer ITEM_TYPE_SUBJECT = 0;

    /**
     * 题目类型：填空题
     */
    public static final Integer ITEM_TYPE_CLOZE = 1;

    /**
     * 题目分数矩阵：主观题
     */
    public static final Map<Long, Integer> ITEM_SCORE_SUBJECT = new HashMap<Long, Integer>() {{
        put(1679744731585830914L, 10);
        put(1679744790041845762L, 15);
        put(1679744835550044161L, 20);
        put(1679744947714121729L, 25);
        put(1679744998528114689L, 30);
    }};

    /**
     * 题目分数矩阵：填空题
     */
    public static final Map<Long, Map<String, Integer>> ITEM_SCORE_CLOZE = new HashMap<Long, Map<String, Integer>>() {{
        put(1679744731585830914L, new HashMap<String, Integer>() {{
            put("C", 5);
            put("B", 10);
            put("A", 15);
        }});
        put(1679744790041845762L, new HashMap<String, Integer>() {{
            put("C", 10);
            put("B", 15);
            put("A", 20);
        }});
        put(1679744835550044161L, new HashMap<String, Integer>() {{
            put("C", 15);
            put("B", 20);
            put("A", 25);
        }});
        put(1679744947714121729L, new HashMap<String, Integer>() {{
            put("C", 20);
            put("B", 25);
            put("A", 30);
        }});
        put(1679744998528114689L, new HashMap<String, Integer>() {{
            put("C", 25);
            put("B", 30);
            put("A", 35);
        }});
    }};


    /**
     * 码表类型：病症类别
     */
    public static final String CODE_TYPE_CATEGORY = "category";

    /**
     * 码表类型：难易级别
     */
    public static final String CODE_TYPE_DIFFICULTY = "difficulty";

    /**
     * 码表禁止删除类型
     */
    public static final List<String> CODE_DELETE_DISABLE_TYPE = new ArrayList<String>() {{
        add(CODE_TYPE_DIFFICULTY);
    }};

    /**
     * 主观题问题标记：诊断
     */
    public static final String SUBJECT_ANS_HEADING_DIAGNOSE = "diagnose";

    /**
     * 主观题问题标记：病机
     */
    public static final String SUBJECT_ANS_HEADING_CAUSE = "cause";

    /**
     * 主观题问题标记：治法
     */
    public static final String SUBJECT_ANS_HEADING_METHOD = "method";

    /**
     * 主观题问题标记：处方
     */
    public static final String SUBJECT_ANS_HEADING_PRESCRIPTION = "prescription";

    /**
     * 主观题问题标记：药物
     */
    public static final String SUBJECT_ANS_HEADING_MEDICINE = "medicine";

    /**
     * 实体缓存前缀：填空题
     */
    public static final String ENTITY_CACHE_ITEM_CLOZE = "ENTITY_CACHE:ITEM:CLOZE";

    /**
     * 实体缓存前缀：主观题
     */
    public static final String ENTITY_CACHE_ITEM_SUBJECT = "ENTITY_CACHE:ITEM:SUBJECT";

    /**
     * 实体缓存前缀：图片
     */
    public static final String ENTITY_CACHE_IMAGE = "ENTITY_CACHE:IMAGE";

    /**
     * 实体缓存前缀：码表
     */
    public static final String ENTITY_CACHE_CODE = "ENTITY_CACHE:CODE";

    /**
     * 实体缓存前缀：码表
     */
    public static final String ENTITY_CACHE_ITEM_BATTLE = "ENTITY_CACHE:ITEM:BATTLE";

    /**
     * 最大加入小组数
     */
    public static final Integer GROUP_JOIN_MAX = 10;

    /**
     * 时间周期天数映射表
     */
    public static final Map<String, Integer> DATE_RANGE_MAP = new HashMap<String, Integer>() {{
        put("day", 1);
        put("week", 7);
        put("month", 30);
    }};

    /**
     * 填空题题目等级：全部
     */
    public static final String CLOZE_ITEM_ANS_RANK_ALL = "all";

    /**
     * 对战题目分数
     */
    public static final Integer BATTLE_ITEM_SCORE = 10;

    /**
     * 对战消息类型
     */
    public static class BattleMsgCode {
        /**
         * 心跳
         */
        public static final String PING = "ping";

        /**
         * 错误
         */
        public static final String ERROR = "error";

        /**
         * 开始匹配
         */
        public static final String START_MATCH = "start_match";

        /**
         * 获取题目
         */
        public static final String TOPIC = "topic";

        /**
         * 批改题目
         */
        public static final String CORRECT = "correct";

        /**
         * 已完成
         */
        public static final String FINISHED = "finished";

        /**
         * 对战详细
         */
        public static final String DETAIL = "detail";

        /**
         * 答案解析
         */
        public static final String DESCRIBE = "describe";

        /**
         * 退出匹配
         */
        public static final String EXIT_MATCH = "exit_match";

        /**
         * 创建房间
         */
        public static final String CREATE_ROOM = "create_room";

        /**
         * 获取房间邀请码
         */
        public static final String INVITATION_CODE = "invitation_code";

        /**
         * 加入房间
         */
        public static final String JOIN_ROOM = "join_room";

        /**
         * 开始对战
         */
        public static final String START = "start";

        /**
         * 获取房间信息
         */
        public static final String ROOM_INFO = "room_info";

        /**
         * 房间销毁
         */
        public static final String ROOM_DESTROY = "room_destroy";
    }

    public static class NotificationType {
        /**
         * 普通通知
         */
        public static final Integer NORMAL = 0;

        /**
         * 重要通知
         */
        public static final Integer IMPORTANT = 1;

        /**
         * 系统通知
         */
        public static final Integer SYSTEM = 2;
    }

    private String jwtSecretKey;

    private String defaultPassword;

    private String defaultPasswordStudent;

    private String defaultPasswordTeacher;

}
